﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicClass.BreedingEnum;
using PublicClass;
using S.Breeding.Domain;
using S.Breeding.Read.Api.Application.Command.BodyMeasureCommand;
using S.Breeding.Read.Api.Application.Command.SheepWeighCommand;
using S.Breeding.Read.Api.Application.Command.ConditionMeasureCommand;
using S.Breeding.Infrastructure;

namespace S.Breeding.Read.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class BreedingController : ControllerBase
    {
        private readonly IMediator mediator;
        private readonly IRepository<SheepWeigh> repository;
        public BreedingController(IMediator mediator, IRepository<SheepWeigh> repository)
        {
            this.mediator = mediator;
            this.repository = repository;
        }

        #region 羊只称重
        /// <summary>
        /// 显示羊只称重
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfo<SheepWeigh>> GetSheepWeigh([FromQuery]SheepWeighListCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 反填羊只称重
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<SheepWeigh> EditSheepWeight([FromQuery]SheepWeighEditCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 显示品种列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetBreed()
        {
            List<object> list = new List<object>();
            foreach (Breed item in Enum.GetValues<Breed>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示称重类型列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetWeightType()
        {
            List<object> list = new List<object>();
            foreach (WeightType item in Enum.GetValues<WeightType>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示性别列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetSex()
        {
            List<object> list = new List<object>();
            foreach (Sex item in Enum.GetValues<Sex>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }


        #endregion

        #region 体尺测定
        /// <summary>
        /// 显示体尺测定
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfo<BodyMeasure>> GetBodyMeasure([FromQuery]BodyMeasureListCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 反填体尺测定
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<BodyMeasure> EditBodyMeasure([FromQuery]BodyMeasureEditCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }
        #endregion

        #region 品相测定
        /// <summary>
        /// 显示体尺测定
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageInfo<ConditionMeasure>> GetConditionMeasure([FromQuery]ConditionMeasureListCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }


        /// <summary>
        /// 反填体尺测定
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ConditionMeasure> EditConditionMeasure([FromQuery]ConditionMeasureEditCommand request, CancellationToken cancellationToken)
        {
            return await mediator.Send(request);
        }

        /// <summary>
        /// 显示牙齿咬合列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetToothType()
        {
            List<object> list = new List<object>();
            foreach (ToothType item in Enum.GetValues<ToothType>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示色斑列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetStain()
        {
            List<object> list = new List<object>();
            foreach (Stain item in Enum.GetValues<Stain>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示嘴颜色列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetMouthColor()
        {
            List<object> list = new List<object>();
            foreach (MouthColor item in Enum.GetValues<MouthColor>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示脂肪分布列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetFatFound()
        {
            List<object> list = new List<object>();
            foreach (FatFound item in Enum.GetValues<FatFound>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示毛发列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetHairs()
        {
            List<object> list = new List<object>();
            foreach (Hairs item in Enum.GetValues<Hairs>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示蹄颜色列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetHoofColor()
        {
            List<object> list = new List<object>();
            foreach (HoofColor item in Enum.GetValues<HoofColor>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }

        /// <summary>
        /// 显示角列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public IActionResult GetAngle()
        {
            List<object> list = new List<object>();
            foreach (Angle item in Enum.GetValues<Angle>())
            {
                list.Add(new
                {
                    name = item.ToString(),
                    value = item
                });
            }
            return Ok(list);
        }
        #endregion
    }
}
